{template 'common/header'}
{if $do=="list"}
<div class="container">
    <div class="row">
        <div class="span12">
            <div class="panel panel-primary">
                <div class="panel-heading">
                    <h3 class="panel-title">
                        所有模块
                    </h3>
                </div>
                <div class="panel-body">
                    <table class="table table-hover">
                        <Tr>
                            <Th>名称</Th>
                            <th>版本号</th>
                            <th>价格</th>
                            <th>状态</th>
                        </Tr>
                        {loop $modules $module}
                        <Tr>
                            <td><a href="{php echo url('module/list',array('mid'=>$module['mid'],'do'=>'detail'))}">{$module['title']}</a>
                            </td>
                            <td>{$module['version']}</td>
                            <td>{php echo $module['price']==0?"免费":"￥".$module['price'];}</td>
                            <td>
                                {if empty($module['dtime'])}
                                <button class="btn btn-primary" onclick='window.location.href = "{php echo url('module/list',array('mid'=>$module['mid'],'do'=>'detail'))}"'>开通</button>
                                {else if $module['dtime']<strtotime(date('Y-m-d'))&&$module['dtime']!=-1}
                                <button class="btn btn-info" onclick='window.location.href = "{php echo url('module/list',array('mid'=>$module['mid'],'do'=>'detail'))}"'>过期</button>
                                {else}
                                <button class="btn btn-success" onclick='window.location.href = "{php echo url('module/list',array('mid'=>$module['mid'],'do'=>'detail'))}"'>已开通</button>
                                {/if}
                            </td>
                        </Tr>
                        {/loop}
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
{/if}
{if $do=="detail"}
<div class="container">
    <div class="panel panel-default">
        <div class="panel-heading">
            <div class="container">
                <div style="padding: 10px 10px 10px 10px;">
                    <form class="bs-example bs-example-form" role="form">
                        <div class="row">
                            <div class="col-lg-100">
                                <div class="input-group">
                    <span class="input-group-btn">
                        <button class="btn btn-default" type="button"> <span class="glyphicon glyphicon-arrow-left"></span></button>
                    </span>
                                    <input type="text" class="form-control" placeholder="搜索全部应用">
                                    <span class="input-group-btn">
                       <button type="button" class="btn btn-info btn-default"> 管理</button>
                        </span>
                                </div><!-- /input-group -->
                            </div><!-- /.col-lg-6 -->

                        </div><!-- /.row -->
                    </form>
                </div>
            </div>
        </div>
        <div class="panel-body">
            <h1 class="text-justify">{$module['title']}</h1>
            <bar>
                <p class="text-left">
                    <button type="button" class="btn btn-danger" onclick="purchase()">购买 {php echo $module['price']==0?"免费":"￥".$module['price'];}
                    </button>
                </p>
        </div>
        <ul class="list-group">
            <li class="list-group-item"><h2>版本号<h2></li>
            <li class="list-group-item">{$module['version']}</li>
            <li class="list-group-item"><h2>功能描述<h2></li>
            <li class="list-group-item">{$module['description']}</li>

        </ul>
    </div>

</div>

<script language="javascript">
    function purchase() {
        if(window.confirm('确认购买？')){
            window.location.href="{php echo url('module/purchase',array('mid'=>$module['mid']))}";
        }
    }
</script>
{/if}